
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-(^6g06ilt%awhx8uznqf!*f$o!eotx=_(c_yjidze)i(sko@77'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'app.apps.AppConfig',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'utils.md.DemoMiddleware',
]

ROOT_URLCONF = 'CNAS1.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates']
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'CNAS1.wsgi.application'

# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    },

    'mysql': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'django',
        'USER': 'root',
        'PASSWORD': '123456',
        'HOST': 'localhost',  # 通常是'localhost'，如果是远程服务器则填写远程服务器的IP地址
        'PORT': '3306',  # 通常是3306
    },

    'default1': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'django',
        'USER': 'AP\liu-421',

        'HOST': 'CN01WPLIU-421C\LABX2010',
        'PORT': '1433',
        'OPTIONS': {
            'driver': 'ODBC Driver 17 for SQL Server',
        },
    }

}

# Password validation
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/5.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/

STATIC_URL = 'static/'

# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000

UNICOM_MENU = {
    1: [
        {"text": "证书统计", 'url': "/stats/"},
        {"text": "新增记录", 'url': "/add/"},
        {"text": "我的证书", 'url': "/list/"},
        {"text": "证书审批", 'url': "/approve/"},

        {"text": "工具管理", 'url': "/tool_list/"},
        {"text": "用户管理", 'url': "/user/"},
        {"text": "证书下载", 'url': "/download/"},
    ],
    2: [
        {"text": "新增记录", 'url': "/add/"},
        {"text": "我的证书", 'url': "/list/"},
    ]
}

UNICOM_PERMISSION = {
    '1': {'add', 'kfc', 'cal_list', 'list_syn', 'list_view', 'tools', 'kfv', 'dwy','lz','ddl', 'report', 'approve', 'logout',
          'approve_view', 'ddg', 'certificate_stats'},
    '2': {'add', 'kfc', 'cal_list', 'list_syn', 'list_view', 'tools', 'kfv', 'dwy','lz','ddl', 'logout', 'ddg', 'certificate_stats'}

}
